// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_MST_COMMON_ITEM
// * CreateDate    : 2011/8/10 11:30:12
// * Creater       : CodeSmith
// * LastChangeDate: 2011/8/10 11:30:12
// * LastChanger   : 2011/8/10 11:30:12
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;
using ESOL.Common;

namespace ESOL.Business.Mst
{
/// <summary>
    /// MstCommonItem
    /// </summary>
    public partial class MstCommonItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objMstCommonItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static MstCommonItemEntity GetMstCommonItem(MstCommonItemEntity objMstCommonItemEntity)
        {
            return DataAccess.SelectSingle<MstCommonItemEntity>(objMstCommonItemEntity);
        }
        public static MstCommonItemEntity GetMstCommonItemByCode(string itemCode)
        {
            if (string.IsNullOrEmpty(itemCode))
            {
                return null;
            }
            MstCommonItemEntity objMstCommonItemEntity = new MstCommonItemEntity();
            objMstCommonItemEntity.ItemCode = itemCode;
            return DataAccess.SelectSingle<MstCommonItemEntity>(objMstCommonItemEntity);
        }
        public static DataTable GetMstCommonItemByCondition(string condition, string orderBy, string rowCount)
        {
            string sql = CommonFunctions.GetSelect(rowCount) + @"* FROM MST_COMMON_ITEM WHERE 1=1 ";
            if (string.IsNullOrEmpty(condition) == false)
            {
                sql += condition;
            }
            if (string.IsNullOrEmpty(orderBy) == false)
            {
                sql += " ORDER BY " + orderBy;
            }
            DataSet ds = DataAccess.SelectDataSet(sql);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0];
            }
            return null;
        }
        public static List<MstCommonItemEntity> GetMstCommonItemListByType(string itemType)
        {
            List<MstCommonItemEntity> list = new List<MstCommonItemEntity>();
            if (string.IsNullOrEmpty(itemType))
            {
                return list;
            }
            MstCommonItemEntity objMstCommonItemEntity = new MstCommonItemEntity();
            objMstCommonItemEntity.ItemType = itemType;
            return DataAccess.Select<MstCommonItemEntity>(objMstCommonItemEntity);
        }
        public static DataTable GetMstCommonItemListForInvChange()
        {
            string sql = "select * from MST_COMMON_ITEM where ITEM_TYPE in ('IMT','IDT')";
            return DataAccess.SelectDataSet(sql).Tables[0];
        }
        
        public static DataTable GetMstCommonItemDtByType(string itemType)
        {
            DataTable dt = new DataTable();
            if (string.IsNullOrEmpty(itemType))
            {
                return dt;
            }
            MstCommonItemEntity objMstCommonItemEntity = new MstCommonItemEntity();
            objMstCommonItemEntity.ItemType = itemType;
            return DataAccess.SelectDataSet(objMstCommonItemEntity).Tables[0];
        }
        public static DataTable GetAllItemType()
        {
            string sql = "SELECT ITEM_TYPE FROM MST_COMMON_ITEM GROUP BY ITEM_TYPE";
            DataSet ds = DataAccess.SelectDataSet(sql);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0];
            }
            return null;
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objMstCommonItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertMstCommonItem(MstCommonItemEntity objMstCommonItemEntity)
        {
            return DataAccess.Insert(objMstCommonItemEntity);
        }

        public static bool InsertMstCommonItem(List<MstCommonItemEntity> objMstCommonItemEntityList)
        {
            return DataAccess.Insert(objMstCommonItemEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objMstCommonItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateMstCommonItem(MstCommonItemEntity objMstCommonItemEntity)
        {
            return DataAccess.Update(objMstCommonItemEntity);
        }

        public static bool UpdateMstCommonItem(List<MstCommonItemEntity> objMstCommonItemEntityList)
        {
            return DataAccess.Update<MstCommonItemEntity>(objMstCommonItemEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objMstCommonItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteMstCommonItem(MstCommonItemEntity objMstCommonItemEntity)
        {
            return DataAccess.Delete(objMstCommonItemEntity);
        }

        public static bool DeleteMstCommonItem(List<MstCommonItemEntity> objMstCommonItemEntityList)
        {
            return DataAccess.Delete<MstCommonItemEntity>(objMstCommonItemEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetMstCommonItemAll()
        {
            return DataAccess.SelectAllDataSet<MstCommonItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<MstCommonItemEntity> GetMstCommonItemAllList()
        {
            return DataAccess.SelectAll<MstCommonItemEntity>();
        }
        #endregion

        #region Functions
        #endregion
    }
	
	
}	

